import { BaseWindow } from "../../../component/window/BaseWindow";
import { Language } from "../../../../extend/language/Language";
import { Global } from "../../../../com/gengine/global/Global";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { ResFileConst } from "../../resource/ResFileConst";
import { GuideArrow } from "../guide/GuideArrow";
import { GuideArrowManager } from "../../manager/GuideArrowManager";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { NavbarIconInfo } from "./navbar/NavbarIconInfo";
import { LoaderManager } from "../../../../com/gengine/resource/LoaderManager";
import { DisplayUtil } from "../../../common/DisplayUtil";
import { EffectManager } from "../../manager/EffectManager";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
type int = number;
//class MainUITipsWindow
    
    export  class MainUITipsWindow extends BaseWindow
    {
        constructor()
        {
            super();
            setSize(510, 380);
            titleHeight = 26;
            title = Language.getString(80198);
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStageHandler);
            this.addEventListener(flash.events.Event.REMOVED_FROM_STAGE, this.onRemovedHandler);
            return;
        }

        public set afterClickFun(arg1: Function)
        {
            this._afterClickFun = arg1;
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            this.x = (Global.stage.stageWidth - this.width) / 2 + 41;
            this.y = (Global.stage.stageHeight - this.height) / 2 - 53;
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._bg = ObjCreate.createBitmap("", 11, 36, this);
            ObjCreate.createBg(11, 281, 484, 88, this);
            this._txDec = ObjCreate.createTextField("", 25, 286, 370, 76, this);
            var loc2;
            this._txDec.multiline = loc2 = true;
            this._txDec.wordWrap = loc2;
            var loc1=this._txDec.defaultTextFormat;
            loc1.leading = 3;
            loc1.color = 8454143;
            this._txDec.defaultTextFormat = loc1;
            ObjCreate.createBg(400, 287, 1, 70, this, ImagesConst.VSpliteLine);
            this._iSeeBtn = ObjCreate.createGLoadedButton(ResFileConst.IknowBtn, 405, 308, 84, 40, this);
            this._arrow = new GuideArrow();
            this._arrow.updateDir(GuideArrowManager.Dir_L);
            this._arrow.x = this._iSeeBtn.x + this._iSeeBtn.width / 2 + 71;
            this._arrow.y = this._iSeeBtn.y - this._iSeeBtn.height + 68;
            return;
        }

        protected /* override */ createDisposedChildrenImpl(): void
        {
            super.createDisposedChildrenImpl();
            if (closeBtn) 
            {
                closeBtn.visible = false;
            }
            return;
        }

        protected onISeeBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (typeof this._afterClickFun === "function") 
            {
                this._afterClickFun();
            }
            this.hide();
            Dispatcher.dispatchEvent(new DataEvent(EventName.MainUIByLevelOpFinish, this._info));
            return;
        }

        public showGuidPanel(arg1: NavbarIconInfo): void
        {
            this.hide();
            this._info = arg1;
            this._txDec.htmlText = arg1.guideDesc;
            LoaderManager.instance.load(arg1.swfURL, this.onLoadComplete, 3, null, null, this.onLoadFail);
            return;
        }

        /* internal  */onRemovedHandler(arg1: Object /* flash.events.Event */): void
        {
            DisplayUtil.removeMe(this._arrow);
            EffectManager.glowFilterUnReg(this._iSeeBtn);
            this.removeEventListener(flash.events.MouseEvent.CLICK, this.onISeeBtnClick);
            return;
        }

        /* internal  */onAddToStageHandler(arg1: Object /* flash.events.Event */): void
        {
            this.addChild(this._arrow);
            var loc1=new Object /* flash.filters.GlowFilter */(268435302, 1, 6, 6, 4);
            var loc2=[loc1];
            EffectManager.glowFilterReg(this._iSeeBtn, loc2, 0.8, 10, 5, 0);
            this.addEventListener(flash.events.MouseEvent.CLICK, this.onISeeBtnClick);
            return;
        }

        /* internal  */onLoadComplete(arg1: Object): void
        {
            this._bg.bitmapData = arg1.bitmapData;
            this.show();
            return;
        }

        /* internal  */onLoadFail(arg1): void
        {
            return;
        }

        public static get instace(): MainUITipsWindow
        {
            if (!MainUITipsWindow._instance) 
            {
                MainUITipsWindow._instance = new MainUITipsWindow();
            }
            return MainUITipsWindow._instance;
        }

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_txDec: Object /* flash.text.TextField */;

        /* internal */ /* var */_type: string;

        /* internal */ /* var */_iSeeBtn: GLoadedButton;

        /* internal */ /* var */_info: NavbarIconInfo;

        /* internal */ /* var */_arrow: GuideArrow;

        /* internal */ /* var */_afterClickFun: Function;

        /* internal */ static /* var */_instance: MainUITipsWindow;
    }
